

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aaaod">
    <el-row>
    <el-col :span="24">
    <!-- {"index":85,"raw":"title","name":"title","cname":"Title","type":{"raw":"varchar2(128)","name":"varchar2","len":128,"dlen":0},"defValue":"","allowNull":false,"constraints":["q","c","u","l","le","v","rows(1)","lw(200)","@title"],"desc":{"raw":"标题","name":"标题"}} -->
    <!--标题 输入控件 -->
    <el-form-item prop="title" label="标题" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.title"  maxlength="128" 
      :rows="1"  type="textarea" show-word-limit  placeholder="请输入标题"  />
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":86,"raw":"prod_id","name":"prod_id","cname":"ProdId","type":{"raw":"number(10)","name":"number","len":10,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","q","c","u","v","tp(readonly,u)","enumurl(/ws/prod/requirement/feedback)","lw(160)","sl(feedback_prod_req,-,#lob_id)","tp(multiselect,q)","ps(full)"],"desc":{"raw":"需求","name":"需求"}} -->
     <!--需求 下拉控件 -->
    <el-form-item prop="prod_id" label="需求" label-width="100px" label-position="right">
      <el-select   v-model="form.prod_id" style="width: 100%" filterable clearable
        placeholder="请选择需求" disabled >
        <el-option v-for="item in prod_idList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":87,"raw":"problem_category","name":"problem_category","cname":"ProblemCategory","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["q","l","c","u","le","v","sl(prod_problem_category)","tp(tag,l)","tp(multicheck)","ps(full)"],"desc":{"raw":"问题分类","name":"问题分类"}} -->
    <!--问题分类 chckbox-group -->
    <el-form-item prop="problem_category" label="问题分类" label-width="100px" label-position="right">
      <el-checkbox-group v-model="form.problem_category"  >
      <el-checkbox-button v-for="item in problem_categoryList" :key="item.value" :label="item.value"  :value="item.value">
        {{item.name}}
        </el-checkbox-button>
      </el-checkbox-group>
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":88,"raw":"description","name":"description","cname":"Description","type":{"raw":"text","name":"text","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["q","c","u","le","v","rows(8)","tp(rtext,c-u)"],"desc":{"raw":"问题说明","name":"问题说明"}} -->
    <!--问题说明 输入控件 -->
    <el-form-item prop="description" label="问题说明" label-width="100px" label-position="right">
      <rtext :html="form.description" :rows="8" @onChange="onRtextdescriptionChange"></rtext>
    </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:"68%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改产品问题",
rules_aaaod:{
    title:[{required:true,message:"请输入标题",trigger: 'blur'}],
    prod_id:[{required:true,message:"请输入需求",trigger: 'blur'}],
    problem_category:[{required:true,message:"请输入问题分类",trigger: 'blur'}],
    description:[{required:true,message:"请输入问题说明",trigger: 'blur'}],
  },
    form:{
        title:"",
        prod_id:"",
        problem_category:[],
        description:"",
    },
    prod_idList:[],
    problem_categoryList:[],
    }
  },
  methods: {
    show(form) {
    this.title = form.title||this.title
      this.conf.visible = true;
      this.loadEnums_aaaod()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.id = form.id
        this.$theia.http.get("/ws/prod/problem",postForm).then(res=>{
          res.problem_category = (res.problem_category+"").split(",")
          that.form = Object.assign(that.form, res)
        //处理枚举重新绑定
          this.loadEnums_aaaod()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `产品问题查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        postForm.problem_category = (postForm.problem_category||[]).join(",")
        this.$theia.http.put("/ws/prod/problem",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '产品问题保存成功',duration:5000})
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `产品问题修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
    onRtextdescriptionChange(text,urls){
      this.form.description = text
      this.form.description_urls = (urls||[]).join(",")
    },
     onUploadSuccess(response){
    },
    loadEnums_aaaod(){
        //需求
        this.prod_idList = this.$theia.enum.get("feedback_prod_req","",this.$theia.user.get("lob_id"),false,"/ws/prod/requirement/feedback")
        //问题分类
        this.problem_categoryList = this.$theia.enum.get("prod_problem_category","","" ,false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>